package com.itliang.web.controller.log;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itliang.core.model.dto.log.SysLoginInfoQueryRequest;
import com.itliang.core.model.entity.SysLoginInfo;
import com.itliang.core.result.BaseResponse;
import com.itliang.core.result.ResultUtils;
import com.itliang.service.log.SysLoginInfoService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author : liangzhuoyuan
 */
@Api(tags = "登录日志管理接口")
@Slf4j
@RestController
@RequestMapping("/admin/log/loginInfo")
public class SysLoginInfoController {

    @Resource
    private SysLoginInfoService sysLoginInfoService;

    /**
     * 分页获取登录日志数据列表
     *
     * @return
     */
    @GetMapping("/list/page")
    public BaseResponse<?> listEquipmentDataByPage(SysLoginInfoQueryRequest queryRequest) {
        QueryWrapper<SysLoginInfo> wrapper = new QueryWrapper<>();
        wrapper.orderByDesc("login_time");
        Page<SysLoginInfo> page = sysLoginInfoService.page(new Page<>(queryRequest.getCurrent(), queryRequest.getPageSize()),wrapper);
        return ResultUtils.success(page);
    }
}
